package com.platform.sys.modular.syncdata.controller;

import com.platform.sys.modular.syncdata.entity.SyncDataTarget;
import com.platform.sys.modular.syncdata.param.SyncDataTargetParam;
import com.platform.sys.modular.syncdata.result.TargetResult;
import com.platform.sys.modular.syncdata.service.SyncDataTargetService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import com.platform.core.pojo.page.PageResult;
import com.platform.core.pojo.response.ResponseData;

import javax.annotation.Resource;
import java.util.List;

/**
 * 同步目标设置控制器
 *
 * @author gyp
 * @date 2022-12-05 11:00:08
 */
@RestController
public class SyncDataTargetController {

    @Resource
    private SyncDataTargetService syncDataTargetService;

    /**
     * 查询同步目标设置
     *
     * @author gyp
     * @date 2022-12-05 11:00:08
     */
    @GetMapping("/syncDataTarget/page")
    public ResponseData<PageResult<SyncDataTarget>> page(SyncDataTargetParam syncDataTargetParam) {
        PageResult<TargetResult> page = syncDataTargetService.page(syncDataTargetParam);
        return ResponseData.success(page);
    }

    /**
     * 添加同步目标设置
     *
     * @author gyp
     * @date 2022-12-05 11:00:08
     */
    @PostMapping("/syncDataTarget/add")
    public ResponseData add(@RequestBody @Validated(SyncDataTargetParam.add.class) SyncDataTargetParam syncDataTargetParam) {
        syncDataTargetService.add(syncDataTargetParam);
        return ResponseData.success();
    }

    /**
     * 删除同步目标设置，可批量删除
     *
     * @author gyp
     * @date 2022-12-05 11:00:08
     */
    @PostMapping("/syncDataTarget/delete")
    public ResponseData delete(@RequestBody @Validated(SyncDataTargetParam.delete.class) SyncDataTargetParam syncDataTargetParam) {
        syncDataTargetService.delete(syncDataTargetParam);
        return ResponseData.success();
    }

    /**
     * 编辑同步目标设置
     *
     * @author gyp
     * @date 2022-12-05 11:00:08
     */
    @PostMapping("/syncDataTarget/edit")
    public ResponseData edit(@RequestBody @Validated(SyncDataTargetParam.edit.class) SyncDataTargetParam syncDataTargetParam) {
        syncDataTargetService.edit(syncDataTargetParam);
        return ResponseData.success();
    }

    /**
     * 查看同步目标设置
     *
     * @author gyp
     * @date 2022-12-05 11:00:08
     */
    @PostMapping("/syncDataTarget/detail")
    public ResponseData<SyncDataTarget> detail(@Validated(SyncDataTargetParam.detail.class) SyncDataTargetParam syncDataTargetParam) {
        return ResponseData.success(syncDataTargetService.detail(syncDataTargetParam));
    }

    /**
     * 同步目标设置列表
     *
     * @author gyp
     * @date 2022-12-05 11:00:08
     */
    @PostMapping("/syncDataTarget/list")
    public ResponseData<List<SyncDataTarget>> list(SyncDataTargetParam syncDataTargetParam) {
        return ResponseData.success(syncDataTargetService.list(syncDataTargetParam));
    }

    /**
     * 导出系统用户
     *
     * @author gyp
     * @date 2022-12-05 11:00:08
     */
    @PostMapping("/syncDataTarget/export")
    public ResponseData export(SyncDataTargetParam syncDataTargetParam) {
        syncDataTargetService.export(syncDataTargetParam);
        return ResponseData.success();
    }

}
